package service

import (
	"context"
	"fmt"
	__ "hospital-srv/basic/proto"
	"hospital-srv/handler/dao"
)

// 查询某天时数据
func (s *Serve) GetOneDaySummarize(_ context.Context, in *__.GetOneDaySummarizeReq) (*__.GetOneDaySummarizeResp, error) {
	data, err := dao.GetOneDayHourData(in.UserId, in.EquipmentId, in.Date)
	if err != nil {
		return nil, err
	}
	var list []*__.SummarizeList
	for _, v := range data {
		get := __.SummarizeList{
			BodyTemperature: v.BodyTemperature,
			BloodSugar:      v.BloodSugar,
			BloodPressure:   v.BloodPressure,
			BloodPressureD:  v.BloodPressureD,
			BloodOxygen:     v.BloodOxygen,
			Date:            in.Date + fmt.Sprintf(" %v:%v", v.CreatedAt.Hour(), v.CreatedAt.Minute()),
		}
		list = append(list, &get)
	}
	return &__.GetOneDaySummarizeResp{
		List: list,
	}, nil
}
